package com.wtwd.campus.adapter;

import com.wtwd.campus.entity.VerifyResult;
import com.wtwd.campus.method.EncryptVerify;
import com.wtwd.campus.service.RedisService;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author ldaoliang
 * @Date create in 9:44 2021/7/5
 * @Description 校验适配器
 */
public abstract class VerifyAdapter {

    private String headerSign = "sign";
    private String headerAccessToken = "Access-Token";
    private String headerManagerToken = "Manager-Token";
    private String headerVcomToken = "AccessToken";
    private String headerJdzcToken="AccessToken";
    private String headerH5MangeToken="AccessToken";

    protected static String post = "post";
    protected static String put = "put";
    protected static String get = "get";
    protected static String delete = "delete";

    protected String sign;
    protected String accessToken;
    protected String managerToken;
    protected String vcomToken;
    protected String JdzcToken;
    protected String h5MangeToken;
    protected EncryptVerify encryptVerify;

    public VerifyAdapter(HttpServletRequest request){
        this.sign = request.getHeader(headerSign);
        this.accessToken = request.getHeader(headerAccessToken);
        this.managerToken = request.getHeader(headerManagerToken);
        this.vcomToken = request.getHeader(headerVcomToken);
        this.JdzcToken=request.getHeader(headerJdzcToken);
        this.h5MangeToken=request.getHeader(headerH5MangeToken);
    }

    /**
     * 校验请求加密是否正确
     * @param request
     * @param redisService
     * @return
     */
    public abstract VerifyResult verifyEncrypt(HttpServletRequest request, RedisService redisService);
}
